<?php include "../public/header.php";?>
<?php include "../public/header_show.php";?>
<body id="xiangqingPage">
<div id="xiangqingBox">
    <div class="page-title">
        <div class="page-title-con">
            <span class="pageshowtitle">详情</span>
            <div class="page-title-opt-list">
                <?php include "../public_flow/flow_show_optbut.php";?>
                <button class="layui-btn layui-btn-sm btn-light marginr5 opt">
                    操作<i class="layui-icon layui-icon-down layui-font-12"></i>
                </button>
                <span id="page-close" class="page-close" onclick="layer_close()">×</span>
            </div>
        </div>
    </div>
    <div class="main-container">
        <div class="tongbox tongbox7">
            <div class="tuo">
                <div class="tit">预算主题</div>
                <div class="con" id="tong_name"></div>
            </div>
            <div class="tuo">
                <div class="tit">预算金额(元)</div>
                <div class="con" id="tong_money"></div>
            </div>
            <div class="tuo">
                <div class="tit">编制日期</div>
                <div class="con" id="tong_biandt"></div>
            </div>
            <div class="tuo">
                <div class="tit">最后变更日期</div>
                <div class="con colorlan" id="tong_biangengdt"></div>
            </div>
            <div class="tuo">
                <div class="tit">项目名称</div>
                <div class="con colorlan" id="tong_enginname"></div>
            </div>
            <div class="tuo">
                <div class="tit">占用金额(元)</div>
                <div class="con" id="tong_zhanfee"></div>
            </div>
            <div class="tuo">
                <div class="tit">剩余金额(元)</div>
                <div class="con" id="tong_shengfee"></div>
            </div>
        </div>
        <div><?php include "../public_flow/flow_show_info.php";?></div>

        <div class="table-box tablenes">
            <div class="title">基本信息</div>
            <table class="layui-table">
                <tbody>
                <tr><td class="tt">项目名称</td><td id="enginname" class="colorlan tv"></td><td class="tt">项目属性</td><td id="business_name" class="tv"></td></tr>
                <tr><td class="tt">预算主题</td><td id="name" class="tv"></td><td class="tt">预算编号</td><td id="number" class="tv"></td></tr>
                <tr><td class="tt">编制人</td><td id="bianer" class="tv"></td><td class="tt">编制日期</td><td id="biandt" class="tv"></td></tr>
                <tr><td class="tt">预算金额(元)</td><td id="money" class="tv"></td><td class="tt">说明</td><td class="tv">预算数据生成后，项目采购合同则必须基于预算</td></tr>
                <tr><td class="tt">备注</td><td id="explain" colspan="3" class="tv"></td></tr>
                </tbody>
            </table>
        </div>

        <div><?php include "../public/upinfo_show.php";?></div>

        <div><?php include "../public_flow/flow_show_flowrelas.php";?></div>

        <div class="table-box tablenes zhanss">
            <script type="text/html" id="toolbarDemo">预算明细</script>
            <div class="tableShow">
                <table id="datalist" lay-filter="datalist"></table>
            </div>
        </div>

        <div><?php include '../public_flow/flow_show_shenlog.php'?></div>
        <div><?php include '../public_flow/flow_show_talk.php'?></div>
        <div><?php include '../public/opt_browse.php'?></div>
    </div>
</div>
<script>
    var param_isdan = getQueryVariable('isdan') || 0;
    if(param_isdan > 0){
        $("#page-close").remove();
    }
    var param_id = getQueryVariable('id') || 0;

    layui.use(['form', 'layer', "laytp",'element','dropdown','laypage','table','soulTable','tree',], function() {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable,element = layui.element;
        var tree = layui.tree,treeTable=layui.treeTable;
        facade.ajax({url: ask_engin_budget_show, data:{id: param_id}}).done(function(res){
            if (res.code === 2000) {
                var data = res.data.data;
                var engininfo = res.data.engininfo;
                var bianinfo = res.data.bianinfo;

                $("#enginname").text(engininfo.name).click(function () {
                    openPage('../engin/show.php?id='+engininfo.id);
                });
                $("#business_name").text(engininfo.business_name);




                $("#tong_name").text(data.name);
                $("#tong_money").text(parseFormatNum(data.money));
                $("#tong_biandt").text(data.biandt);
                if(bianinfo){
                    $("#tong_biangengdt").text(bianinfo.updated_at).click(function () {
                        openPage('../engin_budbian/show.php?id='+bianinfo.id);
                    });
                }
                $("#tong_enginname").text(engininfo.name).click(function () {
                    openPage('../engin/show.php?id='+engininfo.id);
                });
                $("#tong_zhanfee").text(parseFormatNum(data.zhanfee));
                $("#tong_shengfee").text(parseFormatNum(data.shengfee));


                $("#name").text(data.name);
                $("#number").text(data.number);
                $("#bianer").text(data.bianer);
                $("#biandt").text(data.biandt);
                $("#money").text(data.money);
                $("#explain").text(data.explain);



                mytable = treeTable.render({
                    elem: "#datalist",
                    id: "datalist",
                    title: "成本科目",
                    data:res.data.list,
                    // url: facade.url(ask_engin_budsub_list),
                    where: {pid:1},
                    page: true,
                    toolbar: '#toolbarDemo'
                    ,limit:TabInitShow.limit,soulSort: TabInitShow.soulSort,method: TabInitShow.method, overflow: TabInitShow.overflow
                    ,defaultToolbar: TabInitShow.defaultToolbar,filter: TabInitShow.filter ,text: TabInitShow.text
                    ,request: TabInitShow.request,response: TabInitShow.response,contextmenu:get_table_contextmenu(soulTable)
                    , tree: {
                        iconIndex: 0        // 折叠图标显示在第几列
                        , arrowType: 'arrow2'   // 自定义箭头风格
                        , getIcon: function (d) {  // 自定义图标
                            // d是当前行的数据
                            if (d.children && d.children.length > 0) {  // 判断是否有子集
                                return '<i class="laytp-tree-icon laytp-tree-icon-folder"></i>';
                            } else {
                                return '<i class="laytp-tree-icon laytp-tree-icon-file"></i>';
                            }
                        }
                    }
                    , cols: [[
                        {field: 'name', title: '科目',width:300}
                        ,{field:'subid_name',title:'名称及规格',templet: function(d){
                                if(d.ishetong == 1){
                                    return '<span class="colorlan" onclick="openPage(\'../contract_cai/show.php?id='+d.caiid+'\')">'+d.subid_name+'</span>';
                                }else{
                                    return d.subid_name;
                                }
                            }}
                        ,{field: 'unit', title: '单位'}
                        ,{field: 'num', title: '预算数量',align:'right'}
                        ,{field: 'price', title: '预算单价(元)',align:'right'}
                        ,{field: 'money', title: '预算金额(元)',align:'right'}
                        ,{field: 'zhannum', title: '采购数量',align:'right'}
                        ,{field: 'zhanmoney', title: '采购金额(元)',align:'right'}
                        ,{field: 'avamoney', title: '采购均价(元)',align:'right'}
                        ,{field:'shengnum',title:'剩余数量',align:'right',templet: function(d){
                                if(d.shengnum == '/'){
                                    return d.shengnum;
                                }else{
                                    if(d.shengnum < 0){
                                        return '<span class="colorhong">'+d.shengnum+'</span>';
                                    }else{
                                        return d.shengnum;
                                    }
                                }
                            }}
                        ,{field:'shengmoney',title:'剩余金额(元)',align:'right',templet: function(d){
                                if(d.shengmoney == '/'){
                                    return d.shengmoney;
                                }else{
                                    if(d.shengmoney < 0){
                                        return '<span class="colorhong">'+d.shengmoney+'</span>';
                                    }else{
                                        return d.shengmoney;
                                    }
                                }
                            }}
                        ,{field: 'explain', title: '备注'}
                    ]]
                    , done: function (res) {
                        setTimeout(function () {
                            mytable.foldAll();
                            // mytable.expandAll();
                            // mytable.expandAll();
                            // mytable.expandAll();
                            // mytable.expandAll();
                            // mytable.expandAll();
                            // mytable.expandAll();
                            // mytable.expandAll();
                            // mytable.expandAll();
                            // mytable.expandAll();
                        },100)
                    }
                });

                $(".zhanss .layui-table-tool-self").prepend('<div class="layui-inline" style="width:60px!important;line-height: 31px !important;"><div id="shoulist" key="1" class="colorlan" style="cursor: pointer;">全部展开</div></div>');


                //

                $("#shoulist").click(function () {
                    if($(this).attr('key') > 0){
                        mytable.expandAll();
                        $(this).attr('key', 0).text('全部收起');
                    }else{
                        mytable.foldAll();
                        $(this).attr('key', 1).text('全部展开');
                    }

                });

                public_flow_show_display(res.data.billinfo);
                public_upload_show_file('upload_files', res.data.files);
                render_from();
            }
        });

        public_get_readsandlog('engin_budget', param_id);
    });



</script>
</body>
</html>




